package com.yao.longhan.presenter.holder;

import android.os.Bundle;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.android.volley.toolbox.NetworkImageView;
import com.yao.longhan.BaseApplication;
import com.yao.longhan.R;
import com.yao.longhan.constant.Constant;
import com.yao.longhan.model.StoryArticle;
import com.yao.longhan.presenter.BaseHolder;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * Created by heyao on 8/6/17.
 */

public class ChannelHolder extends BaseHolder<StoryArticle> {
    @BindView(R.id.rl_item_book)
    RelativeLayout rlItem;

    @BindView(R.id.iv_item_history)
    NetworkImageView netImage;

    @BindView(R.id.tv_item_history_title)
    TextView tvTitle;

    @BindView(R.id.tv_item_history_description)
    TextView tvDescription;

    @BindView(R.id.tv_item_history_author)
    TextView tvAuthor;

    @BindView(R.id.tv_item_history_serialized)
    TextView tvSerialized;

    @BindView(R.id.tv_item_history_size)
    TextView tvSize;

    public ChannelHolder(View itemView, BaseApplication application) {
        super(itemView, application);
    }

    @Override
    public void bindData(int position, StoryArticle storyArticle) {
        tvTitle.setText(storyArticle.getArtName());
        tvAuthor.setText(storyArticle.getArtAuth());
        tvSerialized.setText(storyArticle.getArtStat());

        rlItem.setTag(R.id.rl_item_book, storyArticle);
    }

    @OnClick(R.id.rl_item_book)
    public void clickItem(View view) {
        StoryArticle storyArticle = (StoryArticle) view.getTag(view.getId());
        if (storyArticle != null) {
            Bundle bundle = new Bundle();
            bundle.putParcelable(Constant.BOOK_INFO, storyArticle);
            mClickListener.clickEvent(bundle);
        }
    }
}
